﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using tmAsk.Common;

namespace tmAsk.Manager
{

    public partial class Admin_ask : System.Web.UI.Page
    {
        function make_htm = new function();//继承类
        tmAsk.Data.MakehtmlSQL SQL = new tmAsk.Data.MakehtmlSQL();
        protected void Page_Load(object sender, EventArgs e)
        {
            function.CheckAdminLogin();

            string page = Request["page"];
            int pageindex = 1;
            if (page == null || page == "")
            {
                pageindex = 1;
            }
            else
            {
                pageindex = Convert.ToInt16(page);
            }

            DataSet rs = SQL.GetList("b_ask", "*", 12, pageindex, "a_id", 1, "");

            this.repeaterid.DataSource = rs;
            this.repeaterid.DataBind();

            dropdownlist1();//下拉列表

        }


        protected void dropdownlist1()
        {
            DataTable ds = SQL.GetList("select * from B_askClass where a_parentid = 0").Tables[0];
            for (int i = 0; i < ds.Rows.Count; i++)
            {
                this.classtype.Items.Add(new ListItem(ds.Rows[i]["a_className"].ToString(), ds.Rows[i]["a_classid"].ToString()));

                DataTable ds1 = SQL.GetList("select * from B_askClass where a_parentid >0 and a_parentid = " + ds.Rows[i]["a_classid"].ToString()).Tables[0];

                for (int ii = 0; ii < ds1.Rows.Count; ii++)
                {
                    classtype.Items.Add(new ListItem("----" + ds1.Rows[ii]["a_className"].ToString(), ds1.Rows[ii]["a_classid"].ToString()));
                }

            }
        }

        public string state(object t)
        {
            int i = Convert.ToInt16(t);
            if (i == 0)
            {
                return "未解决";
            }

            if (i == 1)
            {
                return "已解决";
            }

            if (i == 2)
            {
                return "已关闭";
            }

            return "";

        }

        public string Username(object userid)
        {
            return (new alldata()).username(Convert.ToInt16(userid));
        }

        public string Classname(object classid)
        {
            return (new alldata()).GetClassName(classid.ToString());
        }
    }
}